package com.api.shopapi.mapper;

import com.api.shopapi.entity.NursingSchedulingChangeRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author maochuan
 */
@Repository
@Mapper
public interface NursingSchedulingChangeRecordMapper {
    @Insert("insert into nursing_scheduling_change_record " +
            "(nursingSchedulingChangeRecordCode,NursingSchedulingCode,CreateTime,StaffCode,InstitutionCode,Remarks) " +
            "value (#{nursingSchedulingChangeRecord.NursingSchedulingChangeRecordCode},#{nursingSchedulingChangeRecord.NursingSchedulingCode},#{nursingSchedulingChangeRecord.CreateTime}," +
            "#{nursingSchedulingChangeRecord.StaffCode},#{nursingSchedulingChangeRecord.InstitutionCode},#{nursingSchedulingChangeRecord.Remarks})")
    int insert(@Param("nursingSchedulingChangeRecord") NursingSchedulingChangeRecord nursingSchedulingChangeRecord);

    @Select("select * from nursing_scheduling_change_record where InstitutionCode = #{institutionCode} and " +
            " CreateTime between #{startTime} and #{endTime} " +
            " order by CreateTime desc")
    List<NursingSchedulingChangeRecord> getPageList(@Param("institutionCode")String institutionCode, @Param("startTime")String startTime, @Param("endTime")String endTime);

    @Select("select * from nursing_scheduling_change_record where NursingSchedulingChangeRecordCode=#{nursingSchedulingChangeRecordCode} limit 1")
    NursingSchedulingChangeRecord getByNursingSchedulingChangeRecordCode(@Param("nursingSchedulingChangeRecordCode") String nursingSchedulingChangeRecordCode);

}
